﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using WF_Business;

namespace Business.PubInfo
{
    public class PubInfoManage
    {
        /// <summary>
        /// 读取信息公开数据
        /// </summary>
        /// <param name="i">显示条数</param>
        /// <param name="strBid">大类id</param>
        /// <param name="Sid">小类id</param>
        /// <param name="strWhere">其他条件</param>
        /// <returns></returns>
        public DataTable GetPubInfoList(int i, string strBid, string Sid, string strWhere)
        {
            string sql = "select * from (select art_id,classid,s_id,title,to_char(tjrq,'yyyy-mm-dd') as tjrq,tjrq as tt from ut_pubMsg  where 1=1 ";

            if (!string.IsNullOrEmpty(strBid))
            {
                sql += string.Format(" and classid={0} ", strBid);
            }
            if (!string.IsNullOrEmpty(Sid))
            {
                sql += string.Format(" and s_id={0} ", Sid);
            }

            if (!string.IsNullOrEmpty(strWhere))
            {
                sql += strWhere;
            }
            sql += "order by tt desc )";
            if (i > 0)
            {
                sql += string.Format(" where rownum<={0}", i);
            }
            
            DataTable dtlist;
            SysParams.OAConnection().RunSql(sql, out dtlist);
            return dtlist;
        }

        /// <summary>
        /// 获取公示的图信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetPubTuList()
        {
            string sql = "select * from (select art_id,title,tupian,tu from ut_pubMsg where tu=1 order by tjrq desc) a where  rownum<=5 ";

            DataTable dtlist;
            SysParams.OAConnection().RunSql(sql, out dtlist);
            return dtlist;
        }
    }
}
